﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using JXT.PrimaryKey.Batman.Domain.Models;

namespace JXT.PrimaryKey.Batman.Domain.Repositories.MySql.Expressions
{
    public class WhereQuery<TEntity> : WhereQuery where TEntity : IEntity {
        public void And(Expression<Func<TEntity, bool>> selector) {
            WhereExpressionVisitor whereVisitor = new WhereExpressionVisitor(selector);
            And(whereVisitor.GetQuery());
        }

        public void Or(Expression<Func<TEntity, bool>> selector) {
            WhereExpressionVisitor whereVisitor = new WhereExpressionVisitor(selector);
            Or(whereVisitor.GetQuery());
        }

        public void Init(Expression<Func<TEntity, bool>> selector) {
            WhereExpressionVisitor whereVisitor = new WhereExpressionVisitor(selector);
            var query = whereVisitor.GetQuery();
            Init(query.QueryText, query.Parameters);
        }
    }
}
